#ifndef CAPFPARSER_H_
#define CAPFPARSER_H_

#include "capfnode.h"
#include "cparserstatemanager.h"
#include "ctokenizer.h"
#include "../logger/clogger.h"
#include "../../exception/cunexpectedtokenexception.h"
#include "../../math/cmath.h"

/**
 * CAPFParser - class for parsing of Arcanea Property File
 * @author Michal Rost
 * @date 18.04.2008
 */
class CAPFParser : public CObject {
public:
  static void parseAPF(string fileName, CAPFNode &data, CLogger* logPtr =
      NULL);
  static string getClassName() {
    return "CAPFParser";
  }
protected:
  static void processToken(const vector<CToken> &tokens,
      vector<CToken>::const_iterator ti, int state, CParserStateManager &sm,
      CAPFNode** data, string fileName, CLogger* logPtr);
  static void parseToken(vector<CToken>::const_iterator ti, int state,
      CAPFNode** data, CLogger* logPtr);
  static void parseCSB(vector<CToken>::const_iterator ti, CAPFNode** data);
  static void parseCSE(vector<CToken>::const_iterator ti, CAPFNode** data);
  static void parseAL(vector<CToken>::const_iterator ti, CAPFNode** data);
  static void parseAR(vector<CToken>::const_iterator ti, CAPFNode** data);
  static void parseStr(vector<CToken>::const_iterator ti, CAPFNode** data);
  static const int STATE_DEFAULT = 0;
  static const int STATE_CSB = 1;
  static const int STATE_CSE = 2;
  static const int STATE_SEPARATOR = 3;
  static const int STATE_ASSIGNMENT = 4;
  static const int STATE_AL = 5;
  static const int STATE_AR = 6;
  static const int STATE_STRING = 7;
  static const int STATE_STRINGB = 8;
  static const int STATE_STRINGE = 9;
  static const int TOKEN_COMMENT = CToken::TOKEN_COMMENT;
  static const int TOKEN_STRQUOTATION = CToken::TOKEN_STRQUOTATION;
  static const int TOKEN_EXPRESSION = CToken::TOKEN_EXPRESSION;
  static const int TOKEN_WHITESPACE = CToken::TOKEN_WHITESPACE;
  static const int TOKEN_TABULATOR = CToken::TOKEN_TABULATOR;
  static const int TOKEN_EOLN = CToken::TOKEN_EOLN;
  static const int TOKEN_EOF = CToken::TOKEN_EOF;
  static const int TOKEN_CSTATBEGIN = 8;
  static const int TOKEN_CSTATEND = 9;
  static const int TOKEN_SEPARATOR = 10;
  static const int TOKEN_ASSIGNMENT = 11;
};

#endif
